using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AXBC = Microsoft.Dynamics.BusinessConnectorNet;
using AXMD = Microsoft.Dynamics.Framework.Metadata.Ax;
using Proxy = Microsoft.Dynamics.Framework.BusinessConnector.Proxy;

namespace DynamicsAXPS
{
    [System.Management.Automation.Cmdlet("Get", "AXTableData")]
    public class Get_AXTableData : System.Management.Automation.PSCmdlet
    {
        [System.Management.Automation.Parameter(Position = 0, Mandatory = true)]
        public string Table = "AddressState";

        [System.Management.Automation.Parameter(Position = 1, Mandatory = true)]
        public string[] Fields = new string[] { "*" };

        protected override void ProcessRecord()
        {
            var field_names = this.Fields;
            var fields = DynamicsAXUtil.AXDataUtil.GetReal_fields(this.Table,this.Fields);
            foreach (var field in fields)
            {
                this.WriteVerbose(string.Format("Field: {0}", field));
            }
            var dt = DynamicsAXUtil.AXDataUtil.GetAXTableData(this.Table, fields);
            this.WriteObject(dt);
        }
    }


    [System.Management.Automation.Cmdlet("Get", "AXDataSetData")]
    public class Get_AXDataSetData : System.Management.Automation.PSCmdlet
    {
        [System.Management.Automation.Parameter(Position = 0, Mandatory = true)]
        public string DataSet;

        protected override void ProcessRecord()
        {
            var ds = DynamicsAXUtil.AXDataUtil.GetAXDataSetData(this.DataSet);
            this.WriteObject(ds);
        }
    }

}